using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Utilities;
using IWCommunity.Common;

namespace IWCommunity.Blogs.WebControls
{
    class RssLink : List
    {
        protected override XmlDocument BuildDocument()
        {
            try
            {
                XmlDocument oDoc = new XmlDocument();
                oDoc.LoadXml("<rssLinks/>");
                oDoc.DocumentElement.SetAttribute("rssLink", GetListRssUrl());
                return oDoc;
            }

            catch (Exception ex)
            {
                Logger.LogError(ex);
                XmlDocument oError = new XmlDocument();
                oError.LoadXml(string.Format("<Error>{0}</Error>", ex.Message));
                return oError;
            }
                    
        }

        private string GetListRssUrl()
        {
            SPList oPosts = Web.Lists[ListName]; //try and get list name
            return SPUrlUtility.CombineUrl(Web.Url, "/_layouts/listfeed.aspx?List=" + oPosts.ID);

        }
    }
}
